• Description:
    FOR is a loop, where its variable is after each loop increased/decreased by one, or by given <step> value. FOR is very basic loop, it can be easily simulated by WHILE or REPEAT loops. <step> value can be changed also inside the given loop, but pay attention about this. TO keyword means, that <exp> has at the beginning lower value then the <end>, else use DTO keyword. If you are not sure about it, use WHILE or REPEAT instead. You can also use floats.

  • Syntax:
      FOR <exp> ( TO / DTO ) <end> [ STEP <step> ]
        <statements>
      ENDFOR [ <list> ]
    
      FOR <exp> ( TO / DTO ) <end> [ STEP <step> ] DO <statements> [ IS <list> ]  // see DO keyword
    
      FOR <exp> ( TO / DTO ) <end> [ STEP <step> ] <statement> [ IS <list> ]
    

    where <exp> must be something like: n, n:=2, n:=i*j, etc. It have to contain a variable, or a variable's assignation.

  • Returning values:
    Watch <list> in syntax part. This allows You to return values with FOR statement like:
      a:=FOR...
    
  • Early exit:
    See EXIT/EXITIF